<%@page import="controller.AdminRequestHelper"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    AdminRequestHelper helper = new AdminRequestHelper(request);
    String content = helper.getContent();
    String operation = helper.getOperation();
    String role = helper.getRole();
    ArrayList nameRoles = helper.getNameRoles();
    String currentNameRole = helper.getCurrentNameRole();
    String link = helper.getLink();
    String menu = helper.getMenu();
    request.setAttribute(AdminRequestHelper.contentParameterName, content);
    request.setAttribute(AdminRequestHelper.operationParameterName, operation);
%>
<!DOCTYPE html>
<html>
    <head>
        <link type="text/css" href="../css/main.css" rel="stylesheet">
        <script type="text/javascript" src="../js/jquery.js"></script>       
        <script type="text/javascript" src="../js/<%= role%>.js"></script>
        <% 
            if (link.equals("admin/usercreate.jsp") || link.equals("warehouse/warehouseedit.jsp")) {
        %>
                <script type="text/javascript" src="../js/registration.js"></script>
        <% 
            } else if (link.equals("warehouse/orderview.jsp")) {
        %>
        <% 
            }
        %>
        <title>Administration</title>
    </head>
    <body>

        <%
            if (!role.equals(AdminRequestHelper.courierRoleString)) {
        %>
                <div id="admin-blue-line"></div>
        <%
            }
        %>

        <div style="height: 80px; background: #30363b; width: 100%; position: absolute; top: 0px; border-bottom: 5px solid #ededed;"></div>
        <div id="container">
            <%@include file="header.html" %>
            <div style="position: absolute; top: 55px; right: 10px; color: #FFF;">You are logged as 
                <%
                    for (int i = 0; i < nameRoles.size(); i++) {
                        String current = (String) nameRoles.get(i);
                        if (currentNameRole.equals(current)) {
                %>
                            <span id="role-selected"><%= current%></span>
                <%
                        } else {
                %>
                            <a href="../admin/admin.jsp?role=<%= current%>"><%= current%></a>
                <%
                        }
                            if (i < nameRoles.size() - 1) {
                                out.print(", ");
                            }
                    }
                %>
            </div>

            <jsp:include page="<%= menu%>" flush="true"/>
            <div id="content">
                <jsp:include page="<%= link%>" flush="true"/>
            </div>
        </div>
    </body>
</html>
